import Vue from "vue";
import VueRouter from "vue-router";
const Home = () => import('@/views/home/index.vue');
const Login = ()=> import('@/views/login/index.vue');
const myTask = ()=> import('@/views/myTask/index.vue');
const UserInfo =()=> import('@/views/UserInfo/index.vue');
const ResourceWare =()=> import('@/views/ResourceWare/index.vue');
const TerminalList =()=> import('@/views/TerminalList/index.vue');
const Index =()=> import('@/views/index/index.vue');
const Layout =()=> import('@/views/layout/index.vue');
const Introduction =()=> import('@/views/introduction/index.vue');
const Admin =()=> import('@/views/login/admin.vue');
const AdminHome = ()=> import('@/views/home/admin.vue');
const task = ()=> import('@/views/admin/task.vue');
const container =()=> import('@/views/admin/container.vue')
const ware=()=>import('@/views/admin/ware.vue')
Vue.use(VueRouter);

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}

const routers=[
    {
        path: '/',
        name: 'layout',
        component: Layout,
        redirect:'/index',
        children:[
            {
                path:'index',
                name:'Index',
                component:Index
            },
            {
                path:'introduction',
                name:'Introduction',
                component:Introduction
            },
            {
                path: 'login',
                name: 'Login',
                component: Login
            },
            {
                path: 'login/admin',
                name: 'Admin',
                component: Admin
            },
        ]
    },
    {
        path: '/home',
        name: 'Home',
        component: Home
    },
    {
        path: '/admin/home/',
        name: 'AdminHome',
        redirect: '/admin/home/task',
        component: AdminHome,
        children:[
            {
                path: 'task',
                name: 'Task',
                component: task
            },
            {
                path: 'container',
                name: 'Container',
                component: container
            },
            {
                path: 'ware',
                name: 'Ware',
                component: ware
            },
        ],
    },
    {
        path: '/MyTask',
        name: 'MyTask',
        component: myTask
    },
    {
        path: '/UserInfo',
        name: 'UserInfo',
        component: UserInfo
    },
    {
        path: '/ResourceWare',
        name: 'ResourceWare',
        component: ResourceWare
    },
    {
        path: '/TerminalList',
        name: 'TerminalList',
        component: TerminalList
    }
]
export default routers
